<div class="fsh-rightPanel">
    <label> <input type="password" style="display: none"></label>
    <div class="layui-anim layui-anim-upbit">
        <table id="list_table" class="layui-hide" lay-filter="mainList"></table>
    </div>
</div>
<script>
    layui.use(['layer', 'table'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var tableObj = table.render({//展示已知数据
            elem: '#list_table'
            , cols: [[ //标题栏
                {field: 'id', title: 'ID', sort: true, align: 'center', width: 100},
                {field: 'title', title: '计划名称', align: 'center'}
                , {field: 'yuanxi', title: '所属院系', align: 'center'}
                , {field: 'year', title: '学制', align: 'center'}
                , {field: 'joinTime', title: '创建时间', align: 'center'}
                , {
                    field: 'lock', title: '操作', width: 260, align: 'center', unresize: true,
                    templet: function (d) {
                        return '<a href="javascript:;" class="font-primary" lay-event="find">查看</a>'
                            + '<a href="javascript:;" class="font-primary" lay-event="dispatch">分配</a>'
                            + '<a href="javascript:;" class="font-primary" lay-event="design">修改</a>'
                            + '<a href="javascript:;" class="font-primary" lay-event="del">删除</a>'
                    }
                }
            ]]
            , data: [{
                "id": "10001"
                , "title": "CG系高级建模师培养计划1"
                , "yuanxi": "动漫系"
                , "year": "三年"
                , "joinTime": "2019-10-14"
            }, {
                "id": "10001"
                , "title": "CG系高级建模师培养计划2"
                , "yuanxi": "VR系"
                , "year": "四年"
                , "joinTime": "2019-10-14"
            }]
            // ,skin: 'line' //表格风格
            , even: true
            , page: true //是否显示分页
            //,limits: [5, 7, 10]
            //,limit: 5 //每页默认显示的数量
        });

        // 检索
        $("#search").click(function () {
            reloadTable(tableObj);
        });
        // 添加
        $("#role_add").click(function () {
            showDialog({
                title: '新增计划'
                , template: 'add'
                , yes: function (index, layero) {
                    layer.close(index);
                }

            })
        });
        // 分类
        $("#btn-srot").click(function () {
            $('#dialog_sort').toggle();
        });
        $(".sort-level1 span").click(function () {
            $("#sort_title").html($(this).html())
            $('#dialog_sort').hide();
        });

        //表格内部操作按钮监听
        table.on('tool(mainList)', function (obj) { //注：tool是工具条事件名，mainList是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值

            if (layEvent === 'design') {
                jump('views/school/plan/template/design');
            } else if (layEvent === 'detail') {
                jump('views/common/detail');
            } else if (layEvent === 'dispatch') {
                console.log('aaa');
                showBigDialog({
                    title: '分配班级'
                    , template: 'views/school/homework/template/dispatch.html'
                    , yes: function (index, layero) {
                        layer.close(index);
                    }
                })
            } else if (layEvent === 'del') { // 删除
                layer.confirm('确认删除此课程？', {
                    icon: 7,
                    title: "提示",
                    btn: ['确认', '取消'] //按钮
                }, function () {
                    layer.closeAll();
                });
            }
        });
    });
</script>
